package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void insertOrder(Orders orders);

    //根据订单号修改支付状态
    @Update("update orders set pay_status = #{paid} where number = #{number}")
    void updateStatus(String number, Integer paid);


    List<Orders> queryList(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where id = #{id}")
    Orders queryOrderById(Long id);

    void update(Orders updateOrder);

    List<Orders> queryListByCondition(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders")
    List<Orders> queryOrderList();

    @Update("update orders set status=#{status} where id = #{id}")
    void updateOrderStatus(OrdersConfirmDTO ordersConfirmDTO);

    @Select("select * from orders where status = #{status} and order_time < #{time}")
    List<Orders> queryTimeoutOrderList(Integer status, LocalDateTime time);

    Double sumByMap(Map map);

    Integer getOrderCount(Map map);

}
